var pic = 'https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202102%2F26%2F20210226073347_50f94.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1668131440&t=6df291a148cdb21289e91211d4daea32';
var vm = new Vue({
    el:"#app",
    data:{
        list:[
            {name:"迪丽热巴",jiage:50,count:1,pic},
            {name:"古力娜扎",jiage:20,count:1,pic},
            {name:"杨幂",jiage:40,count:1,pic},
        ]

    },
    methods:{
        sub(item){
            if(item.count>1){
                item.count--;   
            }      
        },
        add(item){
            item.count++;
        },
        clean(){
            this.list=[];
        }
    },
    computed:{
        totalCount(){
           var sum =0;
           this.list.forEach((item)=>{
               sum += item.count;
           });
           return sum;
        },
        totalPrice(){
            var smm =0;
            this.list.forEach((item)=>{
                smm += item.count * item.jiage;
            });
            return smm;
        }
    }
})